package com.ropeok.dao.impl;

import com.ropeok.dao.UserDao;
import com.ropeok.entity.User;
import org.apache.ibatis.annotations.Param;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @BelongsProject: training-mission
 * @BelongsPackage: com.ropeok.dao.impl
 * @Author: zhofeifan
 * @CreateTime: 2022-09-13  10:30
 * @Description: TODO
 * @Version: 1.0
 */
@Repository
public class UserDaoImpl implements UserDao {
    private SqlSessionTemplate sqlSession;
    public void setSqlSession(SqlSessionTemplate sqlSession){
        this.sqlSession =  sqlSession;
    }
    @Override
    public List<User> getUserList() {
        UserDao userDao  = sqlSession.getMapper(UserDao.class);
        return  userDao.getUserList();
    }

    @Override
    public User getUserById(long id) {
        return null;
    }

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public int deleteUser(long id) {
        UserDao userDao  = sqlSession.getMapper(UserDao.class);
        return userDao.deleteUser(id);
    }

    @Override

    public List<User> getUsersByMidKeyword(@Param("keyword")String keyword) {

        UserDao userDao  = sqlSession.getMapper(UserDao.class);
        return  userDao.getUsersByMidKeyword(keyword);
    }

    @Override
    public List<User> getUsersByKeyword(@Param("keyword") String keyword) {
        UserDao userDao  = sqlSession.getMapper(UserDao.class);
        return  userDao.getUsersByKeyword(keyword);
    }

    @Override
    public List<User> getUserByLimit(Map<String, Integer> map) {
        UserDao userDao  = sqlSession.getMapper(UserDao.class);
        return userDao.getUserByLimit(map);
    }
}
